#pragma once
#include<string>
#include <assert.h>
#include <stdio.h>
#include <time.h>
#include<string.h>
#include <errno.h>

namespace FileUtil {

    class AppendFile
    {
    public:
        explicit AppendFile(const std::string& filename);

        ~AppendFile();

        void append(const char* logline, size_t len);

        void flush();

        off_t writtenBytes() const { return writtenBytes_; }

    private:

        size_t write(const char* logline, size_t len);

        FILE* fp_;
        char buffer_[64 * 1024];  //64K
        off_t writtenBytes_;
    };
}
